# 导入flask
# 注册蓝图
from flask import Flask, request
from coupon import bp_coupon
from database import db
# 创建蓝图  添加蓝图路由
from flask import Blueprint
from goods import *
# 导入蓝图
# from apps.users_bp import users_bp


# 初始化
app = Flask(__name__)
# 注册蓝图
app.register_blueprint(bp_coupon, url_prefix='/coupon')
app.register_blueprint(tb_goods, url_prefix='/goods')

# 创建蓝图对象
users_bp = Blueprint('users', __name__)

# 全局配置跨域
from flask_cors import CORS

cors = CORS(app)

app.config['JSON_AS_ASCII'] = False
# # 添加蓝图路由
# @users_bp.route('/index')
# def indext():
#     return 'users bp response'
#
#
# @app.route('/')
# def hello():
#     return "hello world"
#
#
# @app.route('/test')
# def test():
#     return 'test hello world'
#
#
# @app.route('/func')
# def func():
#     return '娃哈哈哈哈哈哈哈哈哈哈哈哈哈哈 hello python'
#
#
# # @app.route('/find')
# # def find():
# #     sql = 'select * from teacher'
# #     res = db.findall(sql)
# #
# #     for i in res:
# #         print(i)
# #     return 'ok'
#
#
# @app.route('/add', methods=['POST', 'GET'])
# def add():
#     # request.from  request.args  request.data
#     username = request.form.get('username')
#     password = request.form.get('password')
#     # 给老师表加入数据
#     sql = "insert into teacher(username,password) values('%s','%s')" % (username, password)
#     db.insert(sql)
#     return 'ok'


if __name__ == '__main__':
    # 查看路由映射
    print(app.url_map)
    app.run(debug=True)
